import winsound
import emulator
from common import show_log

if __name__ == '__main__':
    # emulator.get_sea_area_index()
    # print(emulator.is_found_akashi())
    # emulator.shopping()


    print('Start')
    while True:
        if emulator.is_finish_fight():
            show_log('战斗结束，关闭奖励窗口')
            emulator.close_rewards()
            emulator.delay(2)
            if emulator.click_akashi():
                show_log('找到老板娘')
                winsound.Beep(600, 1000)
                emulator.delay(1)
                emulator.shopping()

            show_log('打开大地图')
            emulator.open_map()
            emulator.delay(1)
            if emulator.close_msgbox():
                show_log('发现弹窗')
                emulator.delay(2)
            else:
                emulator.delay(1)

            show_log('切换地图')
            # 找不到海域时暂停脚本
            if emulator.switch_sea_area() == 0:
                winsound.Beep(600, 1000)
                break
            emulator.delay(3)
            show_log('开始自律战斗')
            emulator.auto_fight()
        else:
            if emulator.click_skip():
                show_log('点击[跳过]按钮')

            # if emulator.find_auto_fight_button():
            #     print('似乎没有自律战斗呢')
            #     winsound.Beep(400, 1000)
            # print('等待2秒')
            emulator.delay(1, 0)
